<html><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link th:href="@{/blog/css/base-new.css}" rel="stylesheet">
    <script th:src="@{/blog/js/jquery-1.8.3.min.js}" ></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.16.0/js/md5.js"></script>

    <!--    <script src="https://www.qingqingblog.com/skin/houtai/main.js"></script>-->
<!--    <script src="https://www.qingqingblog.com/skin/menhu/js/endmenu.js"></script>-->
    <title>用户注册</title>
<!--    <script src="https://www.qingqingblog.com/e/data/js/ajax.js"></script>-->

    <script>
        $(document).ready(function(){
            var deviceId = new Date().getTime();
            //图形验证码
            initImgCheckCode(deviceId);

            $("#btnRegister").click(function(){
                var formParam = $("#registerForm").serializeArray()
                    .reduce(function (json, { name, value }) {
                        json[name] = value;
                        return json;
                    }, {});;

                //校验
                formParam['deviceId'] = deviceId;
                formParam['registerType'] = 2;
                if(formParam.pwd != formParam.pwd2){
                   alert("两次密码必须一样");
                   return;
                }
                formParam['pwd'] = md5(formParam['pwd']);
                // var newParam = {accountNo:'1',pwd:1,email:'1'};

                $.ajax({type:"POST",url:"/user/c/register",dataType:'JSON', contentType:'application/json', data:JSON.stringify(formParam),success:function(result){
                        if(result.success){
                            //设置cookie
                            // var token = result.data.token;
                            alert("注册成功，等待平台审核完成");
                            window.location = "/cmsBlog/index.html";
                        }else{
                            alert(result.message || '注册失败');
                        }

                 }});

                // $.post("/user/c/register",JSON.stringify(formParam),function(result){
                //     if(result.success){
                //         //设置cookie
                //         // var token = result.data.token;
                //         alert("注册成功");
                //         window.location = "/cmsBlog/index.html";
                //     }else{
                //         alert(result.message || '注册失败');
                //     }
                // },"json");
            });
            $("#imgCheckCode").click(function(){
                initImgCheckCode(deviceId);
            });
        });

        function initImgCheckCode(deviceId){
            $.get("/user/c/getImgCode?checkCodeType=0&deviceId="+deviceId,function(res,status){
                $("#imgCheckCode").prop("src",res.data);
            });
        }
    </script>
</head>
<body>






<div class="page-zchy">
    <form id="registerForm" method="post" >
        <h2 class="page-title">用户注册</h2>
        <ul>

            <li> <input name="accountNo" type="text" id="accountNo" maxlength="30" placeholder="用户名"></li>
            <li> <input name="pwd" type="password" id="pwd" maxlength="20" placeholder="密码"></li>
            <li> <input name="pwd2" type="password" id="pwd2" maxlength="20" placeholder="确认密码"></li>
            <li><input name="email" type="text" id="email" maxlength="50" placeholder="邮箱"></li>
            <li>
                <input name="checkCode" type="text" id="checkCode" maxlength="50" placeholder="验证码" style="width:320px">
                <img src="" id="imgCheckCode" style="width:110px;height:30px;float:right;padding:5px 3px">
<!--                <input type="button" id="btnSendCheckCode" value="发送" class="mszc1" style="width:120px;float:right;padding:5px 3px">-->
            </li>

            <input type="button" id="btnRegister" value="注册" class="mszc">



        </ul>
    </form>
</div>

<div class="clear blank60"></div>






</body></html>
